﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using GDoc.Domain;

namespace GDoc.Data
{

    /// <summary>
    /// Instantiate the proper intances for a specific repository interface.
    /// </summary>
    public static class RepositoryFactory
    {

        /// <summary>
        /// Creates a new instance of the IAccountRepository as defined in the Unity configuration section.
        /// </summary>
        /// <returns>The proper <see cref="IAccountRepository"/> instance.</returns>
        public static IAccountRepository CreateAccountRepository()
        {
            return Unity.Current.Container.Resolve<IAccountRepository>();
        }

        /// <summary>
        /// Creates a new instance of the IDocumentDefinitionRepository as defined in the Unity configuration section.
        /// </summary>
        /// <returns>The proper <see cref="IDocumentDefinitionRepository"/> instance.</returns>
        public static IDocumentDefinitionRepository CreateDocumentDefinitionRepository()
        {
            return Unity.Current.Container.Resolve<IDocumentDefinitionRepository>();
        }

        /// <summary>
        /// Creates a new instance of the IUserRepository as defined in the Unity configuration section.
        /// </summary>
        /// <returns>The proper <see cref="IUserRepository"/> instance.</returns>
        public static IUserRepository CreateUserRepository()
        {
            return Unity.Current.Container.Resolve<IUserRepository>();
        }

        /// <summary>
        /// Creates a new instance of the IUserInRoleAccountsRepository as defined in the Unity configuration section.
        /// </summary>
        /// <returns></returns>
        public static IUserRoleInAccountRepository CreateUserRoleInAccountRepository()
        {
            return Unity.Current.Container.Resolve<IUserRoleInAccountRepository>();
        }

        /// <summary>
        /// Creates a new instance of the IUserGroupRepository as defined in the Unity configuration section.
        /// </summary>
        /// <returns>The proper <see cref="IUserGroupRepository"/> instance.</returns>
        public static IUserGroupRepository CreateUserGroupRepository()
        {
            return Unity.Current.Container.Resolve<IUserGroupRepository>();
        }

        /// <summary>
        /// Creates a new instance of the IFileSystemEntriesRepository as defined in the Unity configuration section.
        /// </summary>
        /// <returns></returns>
        public static IFileSystemEntriesRepository CreateFileSystemEntriesRepository()
        {
            return Unity.Current.AzureContainer.Resolve<IFileSystemEntriesRepository>(); ;
        }

        /// <summary>
        /// Creates a new instance of the IFilesRepository as defined in the Unity configuration section.
        /// </summary>
        /// <returns></returns>
        public static IFilesRepository CreateFilesRepository()
        {
            return Unity.Current.AzureContainer.Resolve<IFilesRepository>(); ;
        }
    }
}
